package dai.core.base.camera

import org.joml.Vector3f

open class Camera(val position: Vector3f) {
    val up = Vector3f(0f, 1f, 0f)
    val target = Vector3f(0f,0f,0f)

    val tmpVec3 = Vector3f()


//    fun movePosition(offset:Vector3f){
//        position.add(offset)
//    }

    fun translateX(value:Float,noFly:Boolean = true){
        tmpVec3.set(target.x,target.y,target.z)
        tmpVec3.sub(position).normalize().cross(this.up).mul(value)
        if (noFly){
            tmpVec3.y = 0f
        }
        position.add(tmpVec3)
        target.add(tmpVec3)
    }

    fun translateZ(value:Float,noFly: Boolean = true){
        tmpVec3.set(position.x,position.y,position.z)
        tmpVec3.sub(target).normalize().mul(value)
        if (noFly){
            tmpVec3.y = 0f
        }
        position.add(tmpVec3)
        target.add(tmpVec3)
    }
}